package com.gzw.dms.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.gzw.dms.R;
import com.gzw.dms.bean.DriverInfo;
import com.gzw.dms.bean.ShippingOrderInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/3/9.
 */
public class DriverAdapter extends BaseAdapter {
    private Context mContext;
    private ArrayList<DriverInfo> lsInfo;

    public DriverAdapter(Context _mContext,
                         ArrayList<DriverInfo> _lsInfo) {
        this.mContext = _mContext;
        this.lsInfo = _lsInfo;

    }




    @Override
    public View getView(int arg0, View convertView, ViewGroup arg2) {
        // TODO Auto-generated method stub
        // 加载布局文件
        Holder mHolder;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_driver, null);
            mHolder = new Holder();
            mHolder.tv_driver_name = (TextView) convertView.findViewById(R.id.ic_driver_name).findViewById(R.id.tv_name);
            mHolder.tv_driver_tel = (TextView) convertView.findViewById(R.id.ic_driver_tel).findViewById(R.id.tv_name);
            mHolder.tv_driver_address = (TextView) convertView.findViewById(R.id.tv_driver_address);
            convertView.setTag(mHolder);
        } else {
            mHolder = (Holder) convertView.getTag();
        }

        DriverInfo driverInfo=lsInfo.get(arg0);
        mHolder.tv_driver_name.setText("司机姓名:"+"  "+driverInfo.getDriver_name());
        mHolder.tv_driver_tel.setText("联系电话:"+"  "+driverInfo.getDriver_phone());
        mHolder.tv_driver_address.setText("区域位置:"+"  "+driverInfo.getDriver_address());

        return convertView;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return lsInfo.get(arg0);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return lsInfo.size();
    }

    static class Holder {
        TextView tv_driver_name;
        TextView tv_driver_tel;
        TextView tv_driver_address;

    }
}
